﻿using System;
using System.Windows.Data;
using System.Windows.Media;

namespace zTalk
{
    [ValueConversion(typeof(string), typeof(ImageSource))]
    class AvatarConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter,
            System.Globalization.CultureInfo culture)
        {
            string avatar64 = (string)value;

            return App.DecodeAvatar(avatar64);
        }

        public object ConvertBack(object value, Type targetType, object parameter,
            System.Globalization.CultureInfo culture)
        {
            return Binding.DoNothing;
        }
    }
}
